package com.denlaku.longan.util;

/**
 * @author tianx
 */
public class TimeCost {
    private long startTime;

    private long preStepTime;

    public long getStepTime() {
        long currentTime = System.currentTimeMillis();
        long time = currentTime - preStepTime;
        preStepTime = currentTime;
        return time;
    }

    public long getTotalTime() {
        long currentTime = System.currentTimeMillis();
        long time = currentTime - startTime;
        preStepTime = currentTime;
        return time;
    }

    public static TimeCost getInstance() {
        TimeCost timeCost = new TimeCost();
        timeCost.startTime = System.currentTimeMillis();
        timeCost.preStepTime = timeCost.startTime;
        return timeCost;
    }

}
